<?php

namespace App\Services\Account;

use Illuminate\Database\Eloquent\Relations\HasMany;

class AccountRewards extends AccountAbstract
{
    protected function account(): HasMany
    {
        return $this->user->rewards();
    }

    /*---------- plus --------------------------------------------------------------------------------------------------*/

    public function plusOwnOrderRewards($rewards,$data = [])
	{
		$rewards = big_decimal($rewards);
		$this->record($rewards, 'own_order', '自购佣金返现', $data);
	}
	
	public function plusFirstLevelOrderRewards($rewards,$name, $data = [])
	{
        $rewards = big_decimal($rewards);
		$this->record($rewards, 'first_level', "1区好友 - {$name}购物佣金", $data);
	}

	public function plusSecondLevelOrderRewards($rewards,$name, $data = [])
	{
        $rewards = big_decimal($rewards);
		$this->record($rewards, 'second_level', "2区好友 - {$name}购物佣金", $data);
	}



	/*---------- minus -------------------------------------------------------------------------------------------------*/
	public function minusRewardsToBalances($rewards, $data = [])
	{
		$rewards = big_decimal($rewards)->multipliedBy(-1);
		$this->record($rewards, 'rewards_to_balances', '佣金结算到余额', $data);
	}

	public function minusOrderRefundRewardsByOwn($rewards, $data = [])
	{
        $rewards = big_decimal($rewards)->multipliedBy(-1);
		$this->record($rewards, 'rewards_refund', "自购佣金退回", $data);
	}

	public function minusOrderRefundRewards($rewards,$level,$name, $data = [])
	{
        $rewards = big_decimal($rewards)->multipliedBy(-1);
		$this->record($rewards, 'rewards_refund', "{$level}区好友 - {$name}购物退货佣金退回", $data);
	}

	


	
}
